import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Binar_search 
{
	
	public static void main(String[] args) 
	{
			int num = 10;
			ArrayList<Integer> list = new ArrayList<Integer>(num);
			
			for(int i = 0; i < num; i++)
				list.add(i);
			
			Collections.shuffle(list);
			System.out.println(list);
			buble(list,num);
			System.out.println(list);
			Scanner cin = new Scanner(System.in);
			int  p = cin.nextInt();
			System.out.println(BinarySearch(list,p,0,num-1));
		}
		
		public static int BinarySearch(ArrayList<Integer> list, int p, int s, int e)
		{
			int i = (s + e)/2;
			if (list.get(i) == p) 
				return i;
				if (list.get(i) < p) 
					return BinarySearch(list, p, i + 1, e);
			else 
				return BinarySearch(list, p, s, i - 1);
		}
		
		public static void buble(ArrayList<Integer> list,int num) 
		{
			for(int i = 0; i < num - 1; i++)
			{
				for(int j = 0; j < num - i - 1; j++)
				{
					if(list.get(j) > list.get(j + 1))
					{
						int tmp=list.get(j);
						list.set(j,list.get(j + 1));
						list.set(j + 1, tmp);
						}
					}
				}
			}
	}